import { createApp ,ref } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/reset.css';
import '././assets/font/text.css'
import 'video.js/dist/video-js.css'
import './router/permission.js';

const app = createApp(App)

app.use(Antd)
app.use(router)
app.use(store)

//创建全局的控制登陆页面弹窗，以便其他组件能够唤出该组件
const loginPageShow = ref(false);
app.provide('loginPageShow',loginPageShow);

//创建全局的控制登陆页面弹窗，以便其他组件能够唤出该组件
let bgImgShow = ref(true);
app.provide('bgImgShow',bgImgShow);

//自定义指定防止重复提交
app.directive('noReClick', (el, binding) => {
  function preventReClickFun(elValue, bindingValue) {
    if (!elValue.disabled) {
      elValue.disabled = true
      setTimeout(() => {
        elValue.disabled = false
      }, bindingValue.value || 1000)
    }
  }
  el.addEventListener('click', () => preventReClickFun(el, binding))
  binding.dir.unmounted = function() {
    el.removeEventListener('click', () => preventReClickFun(el, binding))
  }
});

app.mount('#app')
